﻿-var entity = ViewData["entity"] as User
-var userpermissions = ViewData["userpermissions"] as int[]
-var permissions = ViewData["permissions"] as List<Permission>
-var groups = ViewData["groups"] as List<PermissionGroup>
-var isMainNotarius = (ViewData["user"] as User).HasPermission("finance")
.popup
  %form#userpermissionform
    =HTMLHelper.HiddenInput("id", entity.Id)
    %h2=entity.FullName
    %h3 Полномочия:
    %ul.padded5.indent10
      -foreach(var p in permissions.Where(p => (int)PermissionGroupType.System == p.GroupId))
        -if (isMainNotarius || p.Alias != "financeadmin")
          %li
            -bool selected = userpermissions.Contains(p.Id)
            %label.radio{for=String.Format("pid{0}",p.Id)}
              =HTMLHelper.Checkbox("pid", p.Id, "", selected, true)
              =p.Name
    %a.button{href="#", onclick="return saveUserPermission();"} <img src="img/accept.png" class="icon16" /> Сохранить
    %a.button{href="#",onclick="$('#userpermissionedit').remove(); return false;"} <img src="img/delete.gif" class="icon16" /> Отмена 